(ns utests 
(:use clojure.test utils.writeDB utils.readbinfile))


(let [DB (read-bin-file "db-1x2.db")]
  (deftest test-dejopen
    (is (= "Juan      " (pad-string "Juan" 10)))
    (is (= "" (pad-string "" 0)))
    (is (= "sadgas" (pad-string "sadgaskjwjirfewwejrhewgfrewjgkwefr" 6)))
    (is (= "Hotel dejopen       rogomez   " (build-db-record (vec '("Hotel dejopen"
                                                                     "rogomez"))
                                                             (vec '(20 10)))))
                                                             
    (is (= "Key Scrow        NO" (build-db-record (vec '("Key Scrow" "NO"))
                                                  (vec '(17 2)))))
                                                  
    (is (= (cons "key" (for [field (DB :fields)] (get field 0))) (get-field-names DB)))
    (is (= (for [field (DB :fields)] (get field 1))) (get-field-sizes DB))
  )
)

(run-tests)
